package com.elrichuang.productserver.service.impl;

import com.elrichuang.terminator.tri.product.DubboProductServerTriple;
import com.elrichuang.terminator.tri.product.ProductReply;
import com.elrichuang.terminator.tri.product.ProductRequest;
import com.elrichuang.terminator.tri.user.UserReply;
import com.elrichuang.terminator.tri.user.UserRequest;
import com.elrichuang.terminator.tri.user.UserServer;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;

@DubboService
public class ProductServerImpl extends DubboProductServerTriple.ProductServerImplBase {
    @DubboReference
    private UserServer userServer;
    @Override
    public ProductReply sayHello(ProductRequest request) {
        UserRequest userRequest = UserRequest.newBuilder().setName(request.getName()).build();
        UserReply userReply = userServer.sayHello(userRequest);
        return ProductReply.newBuilder().setMessage("Hello, Product " + userReply.getMessage() + "!").build();
    }
}
